/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  7
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      changeDictionaryDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    p
    {
		dimensions		[0 2 -2 0 0 0 0];

        internalField   uniform 0;

        boundaryField
        {
            "solid.*"  
            {
           		type			calculated; 
				value			$internalField;
			}
            frontback
            {
                type            empty;
            }
            "actuator.*"      
            {
				type			calculated; 
				value			$internalField;
            }
        }
    }

    ep
    {
        internalField   uniform 0;

        boundaryField
        {
            solid_left
            {
                type            zeroGradient;
            }
            solid_right
            {
                type            zeroGradient;
            }
            solid_bottom
            {
                type            zeroGradient;
            }
            actuator1_surface
            {
                type            fixedValue;
                value           uniform 1;
            }
            actuator2_surface
            {
                type            fixedValue;
                value           uniform 0;
            }
            frontback
            {
                type            empty;
            }
            solid_to_air
            {
                type            compressible::turbulentTemperatureCoupledBaffleMixed;
                Tnbr            ep;
                kappaMethod     lookup;
                kappa	        epsField;
                value           uniform 0;
            }
        }
    }

    rhoc
    {
        internalField   uniform 0;

        boundaryField
        {
            solid_left
            {
                type            fixedValue;
                value           uniform 0;
            }
            solid_right
            {
                type            fixedValue;
                value           uniform 0;
            }
            solid_bottom
            {
                type            fixedValue;
                value           uniform 0;
            }
            actuator1_surface
            {
                type            zeroGradient;
            }
            actuator2_surface
            {
                type            codedFixedValue;
                value           uniform 1;
                redirectType    myGaussDistribution;
                code
                #{
                    // G(x) = exp(-(x-w)^2 / (2*sigma^2))
                    scalar w = 0.0605, sigma = 0.003; //input values

                    const vectorField& Cf = patch().Cf();
                    scalarField& Vf = *this;

                    forAll(Cf, faceI)
                    {
                        scalar x = Cf[faceI].x();
                        Vf[faceI] = exp(-pow(x-w, 2) / (2.0*pow(sigma,2)));
                    }
                #};
                codeOptions
                #{
                    -I$(WM_PROJECT_DIR)/src/finiteVolume/lnInclude \
                    -I$(WM_PROJECT_DIR)/src/meshTools/lnInclude
                #};
                codeInclude
                #{
                    #include "fvCFD.H"
                    #include <cmath>
                    #include <iostream>
                #};
            }
            frontback
            {
                type            empty;
            }
            solid_to_air
            {
                type            compressible::turbulentTemperatureCoupledBaffleMixed;
                Tnbr            rhoc;
                kappaMethod     lookup;
                kappa	        epsField;
                value           uniform 0;
            }
        }
    }
	//T
    //{
		//dimensions		[0 0 0 1 0 0 0];

        //internalField   uniform 300;

        //boundaryField
        //{
            //solid_left
            //{
                //type            externalWallHeatFluxTemperature;
                //kappaMethod	    solidThermo;
				//mode			coefficient;
				//h				uniform 1e3;
				//Ta				$internalField;
				//value			$internalField;
            //}
            //solid_right
            //{
                //type            externalWallHeatFluxTemperature;
                //kappaMethod	    solidThermo;
				//mode			coefficient;
				//h				uniform 1e3;
				//Ta				$internalField;
				//value			$internalField;
            //}
            //solid_bottom
            //{
                //type            externalWallHeatFluxTemperature;
                //kappaMethod	    solidThermo;
				//mode			coefficient;
				//h				uniform 1e3;
				//Ta				$internalField;
				//value			$internalField;
            //}
            //frontback
            //{
                //type            empty;
            //}
            //actuator1_surface
            //{
                //type            compressible::turbulentTemperatureCoupledBaffleMixed;
                //value           $internalField;
				//Tnbr			T;
				//kappaMethod		solidThermo;
				//qrNbr			qr;
				//qr				none;
            //}
            //actuator2_surface
            //{
                //type            externalWallHeatFluxTemperature;
                //kappaMethod	    solidThermo;
				//mode			coefficient;
				//h				uniform 1e3;
				//Ta				$internalField;
				//value			$internalField;
            //}
            //solid_to_air
            //{
                //type            compressible::turbulentTemperatureCoupledBaffleMixed;
                //value           $internalField;
				//Tnbr			T;
				//kappaMethod		solidThermo;
				//qrNbr			qr;
				//qr				none;
            //}
        //}
    //}
	T
	{
		dimensions		[0 0 0 1 0 0 0];

		internalField   uniform 300;

		boundaryField
		{
			solid_left  
			{
				   type			fixedValue; 
                   value        $internalField;
			}
			solid_right
			{
				   type			fixedValue; 
                   value        $internalField;
			}
			solid_bottom
			{
				   type			fixedValue; 
                   value        $internalField;
			}
			frontback
			{
				type            empty;
			}
            /*
			actuator2_surface      
			{
                type            fixedValue;
                value           uniform 340;
            */
            "actuator.*"
            {
                type            codedFixedValue;
                value           uniform 300;
                redirectType    myTemperatureDistribution;
                code
                #{
                    scalar w = 0.0255, sigma = 0.003; //input values
                    scalar alpha = 1.20e-7, lambda = 0.12;

                    const vectorField& Bf = patch().Cf();
                    scalarField& Tf = *this;
                    scalar t = this->db().time().value();
                    //scalar tt = t / 0.2;

                    forAll(Bf, faceI)
                    {
                        scalar x = Bf[faceI].x();
                        Tf[faceI] = exp(-pow(x-w,2)/(2.0*pow(sigma,2)))*54.0*(1-exp(pow(120,2)*alpha*t/pow(lambda,2))*erfc(sqrt(pow(120,2)*alpha*t/pow(lambda,2)))) + 25.0*(1-exp(pow(30,2)*alpha*t/pow(lambda,2))*erfc(sqrt(pow(30,2)*alpha*t/pow(lambda,2)))) + 300.0;
                    }
                #};
                codeOptions
                #{
                    -I$(WM_PROJECT_DIR)/src/finiteVolume/lnInclude \
                    -I$(WM_PROJECT_DIR)/src/meshTools/lnInclude
                #};
                codeInclude
                #{
                    #include "fvCFD.H"
                    #include <cmath>
                    #include <iostream>
                #};
            }
			}
			solid_to_air
			{
				type            compressible::turbulentTemperatureCoupledBaffleMixed;
				value           $internalField;
				Tnbr			T;
				kappaMethod		solidThermo;
			}
		}
	}
// ************************************************************************* //
